﻿
var CurrentType = 2;
var CurrentData = {};

Ext.onReady(function () {
    PageSafe();


    var docstore = new Ext.data.JsonStore({
        url: Ext.getClassUrl('Flow.FlowView', 'GetDocInfo_suss'),
        root: 'ResponseObject',
        fields: ['PID', 'DocName', 'DocPrice', 'DocCustom', 'IsGoods', 'GoodsCount', 'GoodsName', 'Remark', 'MoreInfo', 'UserID', 'DocState', 'DState', 'LastUpdate', 'NTime'],
        listeners: {
            beforeload: function (st, op) {
                var re = new JsonRequest();
                re.category = CATEGORY.READONLY;
                re.params.info = {
                    SearchName: Ext.getCmp("searchname").getValue(),
                    SearchType: CurrentType
                };
                st.baseParams = re;
                st.proxy.conn.jsonData = re;
            }
        }
    });
    var docsm = new Ext.grid.CheckboxSelectionModel({
        singleSelect: true,
        listeners: {
            rowselect: function () {
                var k = docgrid.getSelectionModel().selections.items;
                if (k.length > 0) {
                    CurrentData = k[0].json;
                }
            },
            rowdeselect: function () {
                CurrentData = {};
            }
        }
    });
    function NumFormat(s, m) {
        m.css = 'RedNum';
        return s;
    }
    var docgrid = new Ext.grid.GridPanel({
        bodyStyle: 'padding:2px',
        border: false,
        split: true,
        height: 500,
        sm: docsm,
        loadMask: true, //加载
        columns: [
       docsm,
       { id: 'DocName', header: '申请单名称', width: 100, dataIndex: 'DocName', sortable: true },
       { id: 'DocPrice', header: '价格', width: 60, dataIndex: 'DocPrice', sortable: true },
       { id: 'DocCustom', header: '客户名称', width: 100, dataIndex: 'DocCustom', sortable: true },
       { id: 'IsGoods', header: '是否物品', width: 80, dataIndex: 'IsGoods', sortable: true },
       { id: 'GoodsName', header: '物品名称', width: 80, dataIndex: 'GoodsName', sortable: true },
       { id: 'GoodsCount', header: '数量', width: 60, dataIndex: 'GoodsCount', sortable: true },
        { id: 'DState', header: '状态', width: 60, dataIndex: 'DState', sortable: true },
       { id: 'NTime', header: '日期', width: 100, dataIndex: 'NTime', sortable: true },
       { id: 'NTime', header: '查看', width: 100, dataIndex: '', sortable: true, renderer: function () {
           return '<a href="#" onclick="DownDoc();">下载查看</a>';
       } 
       }
   ],
        store: docstore
    });



    var page = new Ext.Viewport({
        layout: 'border',
        items: [{
            region: 'center',
            title: '成功申请单',
            iconCls: 'document-icon',
            tbar: ['申请单名称/客户名称：', { xtype: 'textfield', width: 120, height: 23, id: 'searchname' }, { text: '查询', iconCls: 'search-icon', handler: function () { docstore.load(); } }],
            items: docgrid
        }],
        listeners: {
            render: function () {
                docstore.load();
            }
        }
    });
});

var DownDoc = function () {
    window.open("../" + CurrentData.MoreInfo);
}